const { compose, curry } = require("folktale/core/lambda")
const { toUpper, first, split, find } = require("lodash/fp")
const { task } = require("folktale/concurrency/task")
const fs = require("fs")

let f = curry(2, (x, y) => x + y)
// console.log(f(1, 2))
// console.log(f(1)(2))

let composefunc = compose(toUpper, first)
// console.log(composefunc(["one", "two"]))

function readFile(filename) {
  return task(resolver => {
    fs.readFile(filename, "utf-8", (err, data) => {
      if (err) resolver.reject(err)
      resolver.resolve(data)
    })
  })
}
readFile("../../package.json")
  .map(split("\n"))
  .map(find(x => x.includes("version")))
  .run()
  .listen({
    onRejected: err => console.log(err),
    onResolved: value => console.log(value)
  })
